package _base0to1;

import java.util.Arrays;

/**
 * 976. 三角形的最大周长
 */
public class No976 {
    public int largestPerimeter(int[] nums) {
        int answer = 0;
        Arrays.sort(nums);
        for (int i = nums.length - 1; i >= 2; i--) {
            int temp = nums[i];
            int left = i - 2, right = i - 1;
            if (nums[left] + nums[right] > temp) {
                return nums[left] + nums[right] + temp;
            }
        }
        return answer;
    }
}
